<?php
include_once ('head.php');

?>
<div class="container" style="max-width: 1024px;">
	<div class="layui-card">
		<div class="layui-card-header">记录列表</div>
		<div class="layui-card-body">
			<div style="text-align: left;">
				<button type="button" class="layui-btn layui-btn-danger" onclick="dellog()"><i class="layui-icon"></i>全部删除</button>
				<table id="list" class="layui-table"></table>
				
			</div>
		</div>
	</div>
</div>
	<script src="../layui/layui.all.js"></script>
	<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
	<!--您的Layui代码start-->
	<script type="text/javascript">
		layui.use('table',function() {
			var table = layui.table;
			table.render({
				elem: '#list',
				height: 500,
				url: 'Ajax.php?my=loglist', //数据接口
				page: true, //开启分页
				cols: [[ //表头
				{
					field: 'id',
					title: 'ID',
					width: 80
				},{
					field: 'ip',
					title: '操作者IP',
					width: 200
				},{
					field: 'content',
					title: '行为',
					width: 450
				},{
					field: 'date',
					title: '入库日期',
					
				}]]
			});
		});
	
		// 清空压缩包文件
		function dellog(){
			layer.confirm('您确定清空全部日记？', {btn: ['确定', '取消']},function() {
				var index = layer.load(1, {shade: [0.6,'#000']}); //0.1透明度的白色背景
				$.ajax({
					type: "post",   
					url:  "Ajax.php", 
					data: "my=dellog",
					dataType: "json",
					success: function (res) {
						layer.close(index);
						if(res.code==1){
							layer.msg(res.msg,{icon: 6});
							layui.table.reload('list', {
								url: 'Ajax.php?my=loglist'
							});
						}else if(res.code==0){
							layer.msg(res.msg,{icon: 5});
						}
					},
					error: function (res) {
						layer.msg('请求失败',{icon: 5});
						layer.close(index);
					}   
				});
			});
		}
		
	</script>
</body>
</html>
